package com.akcome.hades.repository;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.akcome.hades.domain.BmpIncome;

/**
 * 收益记录Repository接口
 *
 * @author wn
 * @version $v: 1.0.0, $time:2017-12-26 08:49:00 Exp $
 */
public interface BmpIncomeRepository extends JpaRepository<BmpIncome,Long>,JpaSpecificationExecutor<BmpIncome> {

	@Transactional
	@Modifying
	@Query(nativeQuery=true,value="update bmp_income set status='02' where status='01'  and IF(  null!=?1,  DATE_FORMAT(mining_date,'%Y-%m-%d')=?1,  1=1 ) and IF(  null!=?2,  pay_mode=?2,  1=1 ) and IF(  null!=?3,  coin_type=?3,  1=1 )")
	int cleatAudit(String miningDate,String payMode,String coinType);
	
	@Transactional
	@Modifying
	@Query(nativeQuery=true,value="update bmp_income set status='02' where status='01'  and IF(  null!=?1,  DATE_FORMAT(mining_date,'%Y-%m-%d')=?1,  1=1 ) and IF(  null!=?2,  pay_mode=?2,  1=1 ) and IF(  null!=?3,  coin_type=?3,  1=1 )and id in(?4)")
	int cleatAudit(String miningDate,String payMode,String coinType,List ids);
}
